import 'package:flutter/material.dart';

class HouseItem extends StatefulWidget {
  const HouseItem({super.key,required this.houseList});
  final Map<String, dynamic> houseList;

  @override
  State<HouseItem> createState() => _HouseItemState();
}

class _HouseItemState extends State<HouseItem> {
  getStatusText(){
    switch (widget.houseList["status"]) {
      case 1:
        return "待审核";
      case 2:
        return "审核成功";
      case 3:
        return "审核失败";
    }
  }
  getStatusColor(){
    switch (widget.houseList["status"]) {
      case 1:
        return const [
          Color.fromARGB(50, 0, 0, 255),
          Color.fromARGB(255, 0, 0, 255)
        ];
      case 2:
        return const [
          Color.fromARGB(50, 0, 255, 0),
          Color.fromARGB(255, 0, 255, 0)
        ];
      case 3:
        return const [
          Color.fromARGB(50, 255, 0, 0),
          Color.fromARGB(255, 255, 0, 0)
        ];
    }
  }



  @override
  Widget build(BuildContext context) {
    List<Color> colors = getStatusColor();
    return Container(
      padding: const EdgeInsets.all(10),
      decoration: const BoxDecoration(
        color: Colors.white,
      ),
      child: Column(
        children: [
          Row(
            children: [
              Expanded(
                child: 
                Text(widget.houseList["point"])),
              const Spacer(),
              Container(
                padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5),
                decoration: BoxDecoration(
                  color: colors[0],
                  borderRadius: BorderRadius.circular(5),
                ),
                child: Text(
                  getStatusText(),
                  style: TextStyle(
                    color: colors[1],
                  ),
                ),
              )
            ],
          ),
          const SizedBox(height: 15),
          Row(
            children: [
              const Text(
                '房间号',
                style: TextStyle(color: Colors.grey),
              ),
              const Spacer(),
              Expanded(
                child: Text(
                  widget.houseList['room'],
                  textAlign: TextAlign.right,
                ),
              ),
            ],
          ),
          const SizedBox(height: 15),
          Row(
            children: [
              const Text(
                '业主',
                style: TextStyle(color: Colors.grey),
              ),
              const Spacer(),
              Expanded(
                child: Text(
                  widget.houseList['name'],
                  textAlign: TextAlign.right,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
